@extends('layouts.admin')
@section('css')
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_page.css') }}" rel="stylesheet" />
  <link href="{{ asset('admin/assets/advanced-datatable/media/css/demo_table.css') }}" rel="stylesheet">
  <link href="{{ asset('admin/assets/bootstrap-datepicker/css/datepicker.css') }}" rel="stylesheet">
  <link href="{{ asset('admin/assets/bootstrap-daterangepicker/daterangepicker-bs3.css') }}" rel="stylesheet">
@endsection
@section('content')
<section id="main-content">
  <section class="wrapper">
      <!-- page start-->
      <div class="row">
          <div class="col-lg-12">
              <section class="panel">
                  <header class="panel-heading">
                      活动中心
                  </header>
                  <div class="panel-body right"  align="right">
                              
                             <form class="form-inline" action="{{ route('admin.stock.activities') }}" role="form" method="get">
                                  {{ csrf_field() }}
                                  <div class="form-group">
                                      
                                      <label class="sr-only" for="exampleInputEmail2">选择状态</label>
                                          <select class="form-control" name="status">
                                              <option value="-1" {{ -1==$data['status'] ? 'selected':'' }}>所有</option>
                                              <option value="0" {{ 0==$data['status'] ? 'selected':'' }}>等待中</option>
                                              <option value="1" {{ 1==$data['status'] ? 'selected':'' }}>进行中</option>
                                             <option value="2" {{ 2==$data['status'] ? 'selected':'' }}>已结算</option>
                  
                                          </select>
                                      
                                  </div>

                                  <div class="form-group">
                                      <label class="sr-only" for="exampleInputEmail2">用户名</label>
                                      <input type="text" class="form-control tooltips" id="name" data-toggle="tooltip" name="name" value="{{ $data['name'] }}" placeholder="输入用户名">
                                  </div>
                                  <div class="form-group">
                                      <label class="sr-only" for="exampleInputPassword2">电话</label>
                                      <input type="text" class="form-control" id="mobile" name="mobile" value="{{ $data['mobile'] }}" placeholder="输入手机">
                                  </div>

                                  <div class="form-group "  >
                                      <!-- <label class="control-label col-md-3 sr-only">下单时间</label> -->
                                      <!-- <div class="col-md-4" > -->
                                          <!-- <div class="input-group input-large" data-date="13/07/2013" data-date-format="mm/dd/yyyy"> -->
                                              <input type="text" class="form-control dpd1" name="from" value="{{ $data['from'] }}" placeholder="开始日期">
                                              <!-- <span class="">To</span> -->
                                              <!-- <input type="text" class="form-control dpd2" name="to"> -->
                                          <!-- </div> -->
                                          <!-- <span class="help-block">Select date range</span> -->
                                      <!-- </div> -->
                                  </div>
                                  -
                                  <div class="form-group "  >
                                      <!-- <label class="control-label col-md-3 sr-only">下单时间</label> -->
                                      <!-- <div class="col-md-4" > -->
                                          <!-- <div class="input-group input-large" data-date="13/07/2013" data-date-format="mm/dd/yyyy"> -->
                                              <!-- <input type="text" class="form-control dpd1" name="from"> -->
                                              <!-- <span class="input-group-addon">To</span> -->
                                              <input type="text" class="form-control dpd2" name="to" value="{{ $data['to'] }}" placeholder="截止日期">
                                          <!-- </div> -->
                                          <!-- <span class="help-block">Select date range</span> -->
                                      <!-- </div> -->
                                  </div>

                                  <button type="submit" class="btn btn-info">搜索</button>
                              </form>

                          </div>
                  <table class="table table-striped table-advance table-hover">
                      <thead>
                      <tr>
                          <th> ID</th>
                          <th>用户</th>
                          <th>名称</th>
                          <th>发起金额</th>
                          <th>参与次数</th>
                          <th>总金额</th>
                          <th>状态</th>
                          <th>开始时间</th>
                          <th>结束时间</th>
                          <th>创建时间</th>
                          <th>更新时间</th>
                          <th>操作</th>
                      </tr>
                      </thead>
                      <tbody>
                      @foreach($activities as $a)
                      <tr>
                          <th> {{ $a->id }}</th>
                          <th> {{ $a->user->name }}({{ $a->user->mobile }})</th>
                          <th> {{ $a->name }}</th>
                          <th >￥{{ $a->money }}</th>
                          <th>{{ $a->orders->where('status',1)->count() }}</th>
                          <th>{{ $a->orders->where('status',1)->sum('pay_money') }}</th>
                         <th><span class="label {{ $a->statuslabel() }} label-mini"> {!! $a->status() !!}</span></th>
                          <th>{{ date('Y-m-d H:i:s',$a->start_time) }}</th>
                          <th>{{ date('Y-m-d H:i:s',$a->end_time) }}</th>

                          <th>{{ $a->created_at }}</th>
                          <th>{{ $a->updated_at }}</th>
                        
                          <th>
                           
                              <a class="btn btn-primary btn-xs" href="{{ route('admin.stock.activities.details',['id'=>$a->id]) }}">详情</a>
                             <!--  <button class="btn btn-info btn-xs enterprise" data-href="{{ route('admin.finance.withdrawals.enterprise',['id'=>$a->id]) }}">企业</button>
                              <button class="btn btn-danger btn-xs back" data-href="{{ route('admin.finance.withdrawals.back',['id'=>$a->id]) }}">退回</button> -->
                          </th>

                          
                      </tr>
                      @endforeach

                      </tbody>
                  </table>
                  {!! $activities->render() !!}
              </section>
          </div>
      </div>
      <!-- page end-->
  </section>
</section>
@endsection
@section('javascript')
<script type="text/javascript" language="javascript" src="{{ asset('admin/assets/advanced-datatable/media/js/jquery.dataTables.js') }}"></script>
<script type="text/javascript" src="{{ asset('admin/assets/bootstrap-datepicker/js/bootstrap-datepicker.js') }}"></script>
<script type="text/javascript" src="{{ asset('admin/assets/bootstrap-daterangepicker/daterangepicker.js') }}"></script>
 <script src="{{ asset('admin/js/advanced-form-components.js') }}"></script>
 <script type="text/javascript" charset="utf-8">
      
        $(".transfer").click(function () {
            Rbac.ajax.withdrawals({
                confirmTitle: '确定要执行银联转账处理吗?',
                href: $(this).data('href'),
                successTitle: '处理成功'
            });
        });

        $(".enterprise").click(function () {
            Rbac.ajax.withdrawals({
                confirmTitle: '确定要执行企业付款处理吗?',
                href: $(this).data('href'),
                successTitle: '处理成功'
            });
        });

        $(".back").click(function () {
            Rbac.ajax.withdrawals({
                confirmTitle: '确定要执行退款处理吗?',
                href: $(this).data('href'),
                successTitle: '处理成功'
            });
        });

        $(".deleteall").click(function () {
            Rbac.ajax.deleteAll({
                confirmTitle: '确定删除选中的期权?',
                href: $(this).data('href'),
                successTitle: '删除成功'
            });
        });
    
      
  </script>  
@endsection

